cmake_minimum_required(VERSION 3.10)

project(vlog)


if(DEBUG_FLAG)
set(CMAKE_CXX_FLAGS "-ggdb")
set(CMAKE_C_FLAGS "-ggdb")
endif()

if(CHEEK_MEMORY_FLAG)
set(CMAKE_CXX_FLAGS "-fsanitize=address -fsanitize=leak")
set(CMAKE_C_FLAGS "-fsanitize=address -fsanitize=leak")
endif()


set(CMAKE_CXX_FLAGS "$ENV{CXXFLAG} -std=c++20 -rdynamic -O2 -g -fPIC -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations -Wno-unused-result")

set(CMAKE_C_FLAGS "$ENV{CXXFLAG} -std=c11 -rdynamic -O2 -g -fPIC -Wall -Wno-deprecated -Werror -Wno-unused-function -Wno-builtin-macro-redefined -Wno-deprecated-declarations -Wno-unused-result")


message("CMAKE_CXX_FLAGS:" ${CMAKE_CXX_FLAGS})

include_directories(./)
include_directories(/usr/include)
#include(cmake/ClangFormat.cmake)

link_directories(/usr/lib)
link_directories(/usr/lib64)


file(GLOB LIB_SRC 
    "${CMAKE_SOURCE_DIR}/vlog/*.cpp"
    "${CMAKE_SOURCE_DIR}/vlog/appender/*.cpp")

add_library(vlog SHARED ${LIB_SRC})

file(GLOB TEST_FILES "${CMAKE_SOURCE_DIR}/test/*.cpp")

foreach(TEST_FILE ${TEST_FILES})
    get_filename_component(EXEC_NAME ${TEST_FILE} NAME_WE)
    add_executable(${EXEC_NAME} ${TEST_FILE})
    target_link_libraries(${EXEC_NAME} vlog)
    #add_clang_format_target(${EXEC_NAME})
endforeach()

set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
